package com.dvdfe8.crochet.controlador;
/*
import com.dvdfe8.crochet.modelo.entity.Linea;
import com.dvdfe8.crochet.modelo.entity.LineaForm;
import com.dvdfe8.crochet.modelo.entity.Pedido;
import com.dvdfe8.crochet.modelo.service.LineaService;
import com.dvdfe8.crochet.modelo.service.PedidoService;
import java.util.ArrayList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

@Controller
@RequestMapping("/linea")
public class LineaController {
    
    @Autowired
    LineaService lineaService;
    
    @Autowired
    PedidoService pedidoService;
        
    @RequestMapping("/listar/{pedido}")
    public ModelAndView listarLineas(@PathVariable int pedido){
        ModelAndView mav = new ModelAndView("linea/listado");
        Pedido pActual = pedidoService.getPedidoById(pedido);
        ArrayList lineas = (ArrayList)lineaService.getLineasByPedido(pActual);
        Linea nuevaLinea = new Linea();
        nuevaLinea.setPedido(pActual);
        mav.addObject("lineas", lineas);
        return mav;
    }
    
    
    @RequestMapping(value = "/guardar")
    public ModelAndView guardar(@ModelAttribute("LineaForm") LineaForm lineaForm) {

        ArrayList<Linea> lineas = lineaForm.getLineas();

        if(null != lineas && lineas.size() > 0) {                
                for (Linea linea : lineas) {
                     lineaService.crear(linea);
                }
        }
        ModelAndView mav = new ModelAndView("linea/listado");
        mav.addObject("lineas", lineas);
        return mav;
    }
    
}
*/